<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <title>Title</title>
    <%@include file="/common/common_css.jsp"%>
</head>
<body>
    <h1>登录</h1>
    <div class="container" style="width: 500px;border:1px solid #ccc;border-radius: 5px;box-shadow: 0px 0px 5px #888">
        <form action="login/validate" method="post" class="form" >
            <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" class="form-control" name="username" id="username">
                <p class="label"></p>
            </div>
            <div class="form-group">
                <label for="password">密码</label>
                <input type="password" class="form-control" name="password" id="password">
            </div>
            <p class="text-center">
                <button type="submit" class="btn btn-success">登录</button>
            </p>
        </form>
    </div>
    <%@include file="/common/common_js.jsp"%>
    <script>
        $(function () {
           $('input#username').blur(function () {
               var username = $(this).val();
               //ajax
               $.post('login/validate',{"name":username},function (result) {
                   console.log(result);
                   console.log(typeof result);
                   if(result){
                       $('p.label').addClass('label-success').removeClass('label-danger').text("用户名正确");
                   }else{
                       $('p.label').addClass('label-danger').removeClass('label-success').text("用户名失败");
                   }
               });
           }); 
        });
    </script>
</body>
</html>
